import { POST } from '../axios.config.js'
import { downloadInLink, obj2QueryParams } from '@utility/utility'

const base = window.config.ip
const moduleName = `${base}/xn-message`
const evaluate = `${moduleName}/dep-remark`

const URLS = {
  pageRemark: `${evaluate}/pageRemark`,
  exportExcel: `${evaluate}/skipValidation/exportExcel`,
  getEvalOrgs: `${base}/public-uias-api/organ/skipValidation/listRemarkOrgan`,
}

// 获取评价列表
export const getEvalList = ({ keyword, startTime, endTime, orgIdList, rankList }, currentPage, pageSize) =>
  POST(URLS.pageRemark, {
    currentPage,
    pageSize,
    param: {
      keyword,
      startTime,
      endTime,
      orgIdList,
      rankList,
    },
  })

// 导出评价
export const exportExcel = ({ keyword, startTime, endTime, orgIdList, rankList }) => {
  const queryParams = obj2QueryParams({
    keyword,
    startTime,
    endTime,
    orgIdList,
    rankList,
  })
  const href = `${URLS.exportExcel}?${queryParams}` // 导出文件
  downloadInLink(href)
}

// 获取可以评价的单位列表
export const getEvalOrgs = () => POST(URLS.getEvalOrgs, {})
